import axios from "@/utils/axios";
import store from '@/store'

export const postRequest = (url: string, params?: any) => {
  return axios.post(url, params);
}

export const getRequest = (url: string, params?: any) => {
  return axios.get(url, params);
}

export const apis = {
  login: "/su/login/login",//登录、注册 、绑定关系
  bind: "/su/user/bindingRelationship",//激活账号
  user: "/su/user/getUserIdByToken",//用户信息
  // 首页
  banner: "/su/banner/list",//轮播图
  lotteryFee: "/su/mystery/lotteryFee",//抽奖卡片费用
  lottery: "/su/mystery/lottery",//抽奖卡片
  mystery: "/su/mystery/list",//拥有的卡片列表
  sellCard: "/su/mystery/sellCard",//卖出卡片
  mysteryExchange: "/su/mysteryExchange/list",//卡片兑换列表
  exchange: "/su/mysteryExchange/exchange",//卡片兑换
  checkInvestment: "/su/pledgeUser/checkInvestment",//新人加入-检查是否可以加入
  personalData: "/su/user/personalData",//个人数据
  withdraw: "/su/wallet/withdraw",//提币
  // 卡牌空间
  cardList: "/su/cardUser/list",//卡牌列表
  cardDetail: "/su/cardUser/detail",//卡牌详情
  handoverDetails: "/su/cardUserRecode/handoverDetails",//换手记录
  buyCard: "/su/cardUser/buyCard",//购买卡牌
  // NFT专题
  topicCard: "/su/topicCard/list",//专题列表
  topicInfo: "/su/topicCard/topicInfo",//卡牌专题详情
  buyTopic: "/su/topicCard/buyTopic",//购买卡牌
  // 盲盒
  boxInfo: "/su/boxInfo/detail",//卡牌盲盒详情
  buyBox: "/su/boxInfo/buyBox",//购买盲盒
  // NFTS
  nftCollect: "/su/user/nftCollect",//nfts上部汇总数据
  nftList: "/su/user/nftList",//nfts卡牌列表
  nftsDetail: "/su/cardUser/detail",//卡牌详情
  putOnTheShelf: "/su/cardUser/putOnTheShelf",//上架
  offShelf: "/su/cardUser/offShelf",//下架
  transactionList: "/su/cardUserRecode/list",//交易明细
};


export const fetchPersonalData = async () => {
  const {data} = await postRequest(apis.personalData);
  store.commit('setUserData', data);
  return data;
}